package com.yxq.mdt.app.modules.socialcontact.presenter;

import com.yxq.mdt.app.base.BasePresenter;
import com.yxq.mdt.app.modules.socialcontact.model.LiveModel;
import com.yxq.mdt.app.modules.withdraw.bean.WithDrawResultBean;
import com.yxq.mdt.app.net.ApiModel;

/**
 * @author L
 * @time 2019-12-10
 * @describe 密聊$
 */
public class LivePresenter extends BasePresenter<ILiveContract.View, LiveModel> implements ILiveContract.Presenter {
    /**
     * 如果当前页面同时需要 Model 层和 View 层,则使用此构造函数(默认)
     *
     * @param rootView
     * @param model
     */
    public LivePresenter(ILiveContract.View rootView, LiveModel model) {
        super(rootView, model);
    }

    @Override
    public void addOrUpdateVideo(String targetUserId, int liveType, String liveId) {
        mBaseModel.addOrUpdateVideo(targetUserId, liveType, liveId, new ApiModel.CommonCallback<String>() {
            @Override
            public void onSuccess(String data) {
                mRootView.onLoadLiveSuccess(liveType, data);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onLoadLiveFailed(errMsg);
            }
        });
    }

    public void addOrUpdateVideo(String targetUserId, String liveId) {
        mBaseModel.addOrUpdateVideo(targetUserId, liveId, new ApiModel.CommonCallback<String>() {
            @Override
            public void onSuccess(String data) {
                mRootView.onLoadLiveSuccess(3, data);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onLoadLiveFailed(errMsg);
            }
        });
    }

    public void addOrUpdateVoice(String targetUserId, int liveType, String liveId) {
        mBaseModel.addOrUpdateVoice(targetUserId, liveType, liveId, new ApiModel.CommonCallback<String>() {
            @Override
            public void onSuccess(String data) {
                mRootView.onLoadLiveSuccess(liveType, data);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onLoadLiveFailed(errMsg);
            }
        });
    }

    public void addOrUpdateVoice(String targetUserId, String liveId) {
        mBaseModel.addOrUpdateVoice(targetUserId, liveId, new ApiModel.CommonCallback<String>() {
            @Override
            public void onSuccess(String data) {
                mRootView.onLoadLiveSuccess(3, data);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onLoadLiveFailed(errMsg);
            }
        });
    }

    public void updateEvaluate(String liveId, String comment, int score) {
        mBaseModel.updateEvaluate(liveId, comment, score, new ApiModel.CommonCallback<WithDrawResultBean>() {
            @Override
            public void onSuccess(WithDrawResultBean data) {
                mRootView.onCommentSuccess(data);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onCommentFailed(errMsg);
            }
        });
    }
}
